<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>类-使用super调用超类</title>
    </head>
    <body>
        <h1>类-使用super调用超类</h1>
        <p>来源:<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes">https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes</a></p>
        <script>
            class Cat { 
              constructor(name) {
                this.name = name;
              }
              
              speak() {
                console.log(this.name + ' makes a noise.');
              }
            }

            class Lion extends Cat {
              speak() {
                super.speak();
                console.log(this.name + ' roars.');
              }
            }
            var lion = new Lion('狮子');
            lion.speak();
        </script>
    </body>
</html>